<?php

declare(strict_types=1);

namespace app\admin\controller;

use think\facade\View; //模板引擎
use app\common\Base;
use app\model\Menus; //引入菜单
use app\model\Admin;
use think\facade\Request;
use app\model\GoodsCat;

/**
 * @name 首页
 */
class Index extends Base
{
    /**
     * @name 首页界面
     */
    public function index()
    {
        // dump(base_path());
        $menus = Menus::list([['is_show', '=', '1']]);
        View::assign('menus', grades($menus)); //菜单
        return View::fetch();
    }

    /**
     * @name 欢迎首页
     */
    public function home()
    {
        $info = array(
            '操作系统' => PHP_OS,
            '运行环境' => $_SERVER["SERVER_SOFTWARE"],
            'PHP运行方式' => php_sapi_name(),
            'ThinkPHP版本' => constant('THINK_VERSION'),
            '上传附件限制' => ini_get('upload_max_filesize'),
            '执行时间限制' => ini_get('max_execution_time') . '秒',
            '服务器时间' => date("Y年n月j日 H:i:s"),
            '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600),
            '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]',
            '剩余空间' => round((disk_free_space(".") / (1024 * 1024)), 2) . 'M',
            'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF",
        );
        // dump($info);
        View::assign('info', $info);
        if (request()->isPost()) {
            $param = Request::param();
            $list = Admin::diarylist('', (int)$param['limit'], (int)$param['page']);
            return getBack(0, '', $list['data'], $list['count']);
        }
        return View::fetch();
    }

    /**
     * @name 图标页面
     */
    public function icon()
    {
        return View::fetch('public/icon');
    }
}
